<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>选择原料</title>
  <meta name="keywords" content="">
  <meta name="description" content="">

  <link rel="shortcut icon" th:href="@{/favicon.ico}">
  <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
  <link th:href="@{/css/font-awesome.css}" rel="stylesheet">
  <link th:href="@{/css/animate.css}" rel="stylesheet">
  <link th:href="@{/css/style.css}" rel="stylesheet">
  <link th:href="@{/self/self-common.css}" rel="stylesheet">

  <link th:href="@{/css/plugins/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet">
  <link th:href="@{/css/plugins/bootstrap-select/bootstrap-select.css}" rel="stylesheet">

  <!-- Sweet Alert -->
  <link th:href="@{/css/plugins/sweetalert/sweetalert.css}" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="row">
    <div class="col-sm-12 search-card">
      <div class="ibox">
        <div class="ibox-content">
          <form class="form-inline">
            <div class="form-group searchCX">
              <input id="stock_code" class="form-control" type="text" placeholder="请输入原料编号" clearable>
            </div>
            <div class="form-group searchCX">
              <input id="stock_name" class="form-control" type="text" placeholder="请输入原料名称" clearable>
            </div>

            <div class="form-group">
              <button id="btnSearch" onclick="querySearch()" class="btn btn-purple" type="button">
                <i class="fa fa-search"></i>
                查询
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>

    <div class="col-sm-12 table-card">
      <div class="ibox ">
        <div class="ibox-title">
          <h5>
            <i class="fa fa-bookmark"></i>
            原料列表
          </h5>
        </div>
        <div class="ibox-content">
          <!--              <div id="toolbar">
                            <form class="form-inline">
                                <div class="btn-group">
                                    <button class="btn btn-success" type="button" data-toggle="modal" data-target="#myModalAdd">
                                        <i class="fa fa-plus-circle"></i>
                                        选择
                                    </button>
                                </div>


                            </form>
                        </div>-->
          <table id="dataTable" data-mobile-responsive="true"></table>
        </div>
      </div>
    </div>
  </div>


</div>


<!-- 全局js -->
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/content.js}"></script>
<script th:src="@{/js/app.js}" type="text/javascript"></script>

<!-- Bootstrap table -->
<script th:src="@{/js/plugins/bootstrap-table/bootstrap-table.min.js}"></script>
<script th:src="@{/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js}"></script>
<script th:src="@{/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<!--提示框-->
<script th:src="@{/js/plugins/layer/layer.min.js}"></script>
<!--下拉选择框-->
<script th:src="@{/js/plugins/bootstrap-select/bootstrap-select.js}"></script>
<!--日期-->
<script th:src="@{/js/plugins/layer/laydate/laydate.js}"></script>

<!--bootstrap导出-->
<script th:src="@{/js/plugins/bootstrap-table-export/bootstrap-table-export.js}"></script>
<script th:src="@{/js/plugins/bootstrap-table-export/tableExport.js}"></script>
<!--pdf导出 文本乱码问题-->
<script th:src="@{/js/plugins/bootstrap-table-export/pdfmake/pdfmake.min.js}"></script>
<script th:src="@{/js/plugins/bootstrap-table-export/pdfmake/gbsn00lp_fonts.js}"></script>
<!--将表导出为PDF文件-->
<script th:src="@{/js/plugins/bootstrap-table-export/pdfmake/jspdf.min.js}"></script>
<script th:src="@{/js/plugins/bootstrap-table-export/pdfmake/jspdf.plugin.autotable.js}"></script>

<script th:src="@{/js/plugins/sweetalert/sweetalert.min.js}"></script>

<script>

  var stockTypeId = 1;

  var  stockName=''
  var stockId=''

  var stockSn=''


  function querySearch(){
    stockSn= $.trim($("#stock_code").val())
    stockName= $.trim($("#stock_name").val())
    $('#dataTable').bootstrapTable('refresh');
  }

  $(document).ready(function () {
    function queryParams(params) {
      return {
        pageSize: params.pageSize,
        pageNumber: params.pageNumber,
        stockSn: stockSn,
        stockName: stockName,
        stockTypeId: stockTypeId,
      }
    }
    $('#dataTable')
            .bootstrapTable({
              url: baseUrl + "getStockPageList",
              method: "post",
              queryParamsType: "",
              queryParams: queryParams,
              pageNumber: 1,
              pageSize: 10,
              striped: true,
              cache: false,
              search: false,
              pagination: true,
              showRefresh: true,
              showToggle: true,
              showColumns: true,
              formatSearch: function () {
                return "供应商列表";
              },
              iconSize: 'outline',
              sidePagination: "server",
              showExport: false,
              buttonsAlign: "right",
              exportTypes: ['excel'],
              pageList: [10, 20, 30, 'all'],
              exportDataType: "basic",
              toolbar: '#toolbar',
              icons: {
                refresh: 'glyphicon-repeat',
                toggle: 'glyphicon-list-alt',
                columns: 'glyphicon-list',
                export: 'glyphicon-export'
              },
              exportOptions: {
                ignoreColumn: [7],
                fileName: '供应商信息'
              }
              , responseHandler: function (res) {

                var rows = [];
                if (res.total !== 0) {
                  rows = res.list;
                }
                var result = {
                  rows: rows,
                  total: res.total
                };
                return result;
              },
              onEditableSave: function (field, row, oldValue, $ele) {


              },
              columns: [{
                field: 'stockSn',
                title: '原料编号',
                formatter: function (value, row, index) {
                  if (value == null) {
                    return '';
                  } else {
                    return value;
                  }
                }
              }, {
                field: 'stockName',
                title: '原料名称',
                formatter: function (value, row, index) {
                  if (value == null) {
                    return '';
                  } else {
                    return value;
                  }
                }
              }, {
                field: 'stockNameEnglish',
                title: '英文名称',
                formatter: function (value, row, index) {
                  if (value == null) {
                    return '';
                  } else {
                    return value;
                  }
                }
              }, {
                field: 'stock_type_name',
                title: '原料类型',
                formatter: function (value, row, index) {
                  if (value == null) {
                    return '';
                  } else {
                    return value;
                  }
                }
              },

                {
                  field: 'model',
                  title: '规格型号',
                  formatter: function (value, row, index) {
                    if (value == null) {
                      return '';
                    } else {
                      return value;
                    }
                  }
                },

                {
                  field: 'storageCondition',
                  title: '存储条件',
                  formatter: function (value, row, index) {
                    if (value == null) {
                      return '';
                    } else {
                      return value;
                    }
                  }
                },{
                  field: 'manufacturer',
                  title: '制造商',
                  formatter: function (value, row, index) {
                    if (value == null) {
                      return '';
                    } else {
                      return value;
                    }
                  }
                },
                // {
                //   field: 'supplier',
                //   title: '供应商',
                //   formatter: function (value, row, index) {
                //     if (value == null) {
                //       return '';
                //     } else {
                //       return value;
                //     }
                //   }
                // }, {
                //   field: 'createTime',
                //   title: '创建时间',
                //   formatter: function (value, row, index) {
                //     if (value == null) {
                //       return '';
                //     } else {
                //       return value;
                //     }
                //   }
                // },
                // {
                //   field: 'personnelName',
                //   title: '创建人',
                //   formatter: function (value, row, index) {
                //     if (value == null) {
                //       return '';
                //     } else {
                //       return value;
                //     }
                //   }
                // }, {
                //   field: 'remarks',
                //   title: '备注',
                //   formatter: function (value, row, index) {
                //     if (value == null) {
                //       return '';
                //     } else {
                //       return value;
                //     }
                //   }
                // }
              ],
              onClickRow: function(row, $element) {
                $('.info').removeClass('info');
                $($element).addClass('info');
                stockId = row.id;
                stockName = row.stockName;
              }
            });

  });


  var submit = function ()
  {
    if(stockId == "")
    {
      layer.msg("请选择一条供应商信息");
      return '';
    }
    var param = {
      stockName: stockName,
      stockId:stockId
    };

    return JSON.stringify(param);
  }

</script>

</body>

</html>


